"""
用于流式数据测试(例如视频作为输入源进行测试)
"""
from ultralytics import YOLO
import cv2
import matplotlib.pyplot as plt


def run():
    # 关于配置参数,例如此处的task,参考文件在ultralytics/ultralytics/cfg/default.yaml
    # yolo = YOLO("yolov8n.pt")
    # yolo = YOLO("./runs/detect/train4/weights/best.pt")
    yolo = YOLO(R"F:\Project\DeepLearning\YOLOv8\material\out\20240204_pure100_train18\weights\best.pt")
    # 检测视频
    # result = yolo.predict(source=R"F:\Work\other\LiChao\original\方位90俯仰45\方位90俯仰45.avi", show=True)
    # result = yolo.predict(source=R"F:\Work\other\LiChao\original\方位90俯仰45\方位90俯仰45_gray.mp4", show=True)
    # result = yolo.predict(source=R"F:\Work\other\LiChao\original\方位90俯仰45\方位90俯仰45_gray0.mp4", show=True)
    # result = yolo.predict(source=R"F:\Work\other\LiChao\original\方位90俯仰45\方位90俯仰45_录制.mp4", show=True)
    result = yolo.predict(source=R"F:\Work\other\LiChao\original\cross\cross1.mp4", show=True)

    # result = yolo.predict(source="screen",show=True)

    # 从摄像头检测
    # result = yolo.predict(source=1, show=True)

    # plt.imshow(result[0].plot()[:, :, [2, 1, 0]])
    # cv2.imshow("1", result[0].plot())
    # cv2.waitKey()

    # 检测屏幕
    # yolo(source="screen")
    # 摄像头作为检测源
    # yolo(source=0, show=True)


if __name__ == '__main__':
    run()
